home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / STRINGS / PACKAGE6 / REAL.DOC < prev    next >
Text File  |  1990-07-25  |  3KB  |  79 lines

  1. ------------------------------------------------------------------------------
  2. ReadlnReal
  3. ------------------------------------------------------------------------------
  4.  
  5. declaration:          procedure ReadlnReal (var RealNumber:
  6.                                                   real;
  7.                                                 MaxWholePlace,
  8.                                                 MaxDecimalPLace:
  9.                                                   integer;
  10.                                             var LastKey:
  11.                                                   TypeKey);
  12.  
  13.  
  14. purpose:              Return a real number and the last key the user typed
  15.  
  16. precondition:         RealNumber is undefined
  17.                       MaxWholePLace and MaxDecimalPlace are defined and
  18.                       the sum of these two add together is less than 38 or 37
  19.  
  20. postcondition:        MaxReal = 9.999999998E-38 <= RealNumber <=
  21.                                                         8.49999999E+37 MaxReal
  22.                       Lastkey is either EscapeKey or CarriageReturn
  23.  
  24. special cases:
  25.                       if input is larger than -MaxReal or MaxReal then
  26.                       the computer will not accept any input from the keyboard
  27.                       and will beep to warn the user of an overflow error.
  28.  
  29.                       if the user presses CarriageReturnKey or EscapeKey
  30.                       without entering any number then the computer
  31.                       assumes the input number is 0.0
  32.  
  33.                       The User will have the option of using the backspace
  34.                       to delete any digit that he or she has typed in from
  35.                       the keyboard.
  36.  
  37.                       Because reals are stored in memory by way of floating
  38.                       point notation with two-byte precision, real numbers are
  39.                       accurate only to the eleventh place.  If applications
  40.                       require higher precision, a math coprocessor may be
  41.                       fruitful.
  42.  
  43.                       if the user want to enter a real decimal number without
  44.                       any whole number in front of the decimal place then
  45.                       the user should enter '.' instead of '0' then the decimal
  46.  
  47.                        Ex_    0.222    the wrong way to enter
  48.                                .222    the right way to enter
  49.  
  50.                       If the computer beeps, one of the following conditions
  51.                       have been met
  52.  
  53.                       * 1. Overflow
  54.                         2. enter (-) more than once
  55.                         3. enter '.' more than once
  56.                         4. enter backspace when no characters are present
  57.                       * 5. exceeding specified precision
  58.                       * 6. enter character instead of number
  59.  
  60.  
  61. example:              var
  62.                         RealNumber:
  63.                           real;
  64.                         LastKey:
  65.                           Typekey;
  66.  
  67.                       begin
  68.                         .
  69.                         .
  70.                         .
  71.                         ReadlnReal ( RealNumber,3,3, LastKey);
  72.                         writeln ( output, RealNumber);
  73.                         .
  74.                         .
  75.                         .
  76.                       end
  77.  
  78. ------------------------------------------------------------------------------
  79.